private _axis = worldSize / 2;
private _list_house = [_axis, _axis] nearObjects ["House", _axis];

{
	if(_x getVariable["is_guard", false]) then{}else
	{
		private _obj = _x;
		private _list = _obj nearObjects ["House", 500];
		{
			_x setVariable["is_guard", true];
		}forEach _list;
		
		private _level = 0;
		private _ai_num = 0.25;
		
		if(count _list >= 20) then
		{
			_level = 1;
			_ai_num = 0.5; 
		};
		if(count _list >= 50) then
		{
			_level = 2;
			_ai_num = 0.75;
		};
		if(count _list >= 100) then
		{
			_level = 3;
			_ai_num = 1.0; 
		};
		
		//if(Param_Debug == 1) then{_ai_num = _ai_num + 10};
		if(random 100 < as_num_g2) then{
			[2, 0, getPos _obj, 0, _ai_num, _level] spawn fn_createGN;
		};
	};
}forEach _list_house;

/*
fnc_createBuildingGuard =
{
	private _player = objNull;
	waitUntil{sleep 1;_player = call fn_getLivePlayer;!isNull _player};
	
	//systemChat "ss";
	
	private _list = [];
	_list = _player nearObjects ["House", 1800];
	_list = _list select 
	{
		private _make = true;
		//防止重复生成
		if(_x getVariable["is_guard", false]) then
		{
			_make = false;
		}
		else
		{
			//防止玩家附近生成
			private _building = _x;
			{
				if(_x distance _building < 500) exitWith
				{
					_make = false;
				};
			}forEach (call fn_getPlayerRed);
		};
		_make
	};
	if((count _list) != 0) then
	{
		private _obj = selectRandom _list;
		
		
		_list = _obj nearObjects ["House", 300];
		{
			_x setVariable["is_guard", true];
		}forEach _list;
		
		private _level = asu_i_c;
		private _ai_num = call fn_aiNum * 0.55;
		
		if(count _list >= 20) then
		{
			_level = asu_i_g;
			_ai_num = call fn_aiNum * 0.85; 
		};
		if(count _list >= 50) then
		{
			_level = asu_i;
			_ai_num = call fn_aiNum * 1.25;
		};
		if(count _list >= 100) then
		{
			_level = asu_b;
			_ai_num = call fn_aiNum * 1.85; 
		};
		
		if(Param_Debug == 1) then{_ai_num = _ai_num + 10};
		[getPos _obj, _ai_num, _level] call fn_createGroup2;
	};
	
	
};

[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;
[] spawn fnc_createBuildingGuard;
sleep 1;


while{true}do
{
	waitUntil{sleep 10;call fn_canSpawnAI};

	
	[] spawn fnc_createBuildingGuard;
	sleep 90;
	
	[] spawn fnc_createBuildingGuard;
	sleep 90;
	
	[] spawn fnc_createBuildingGuard;
	sleep 90;
	
	[] spawn fnc_createBuildingGuard;
	sleep 90;
};

*/

